import request from '@/router/axios'

const files = require.context('./modules', false, /\.js$/)
const apiGenerators = files.keys().map(key => files(key).default)

let api = {}
api.request = request
apiGenerators.forEach(generator => {
  const apiInstance = generator()
  for (const apiName in apiInstance) {
    if (apiInstance.hasOwnProperty(apiName)) {
      // if (apiName === 'fetchSelectDsList') {
      //   console.log('api =>', apiName, apiInstance[apiName])
      // }
      api[apiName] = apiInstance[apiName]
    }
  }
})

export default api
